﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ShortLink.Common.Enums
{
    public static class BizCodeEnumExtensions
    {
        public static string GetMessage(this BizCodeEnum code)
        {
            var field = code.GetType().GetField(code.ToString());
            var attribute = (DescriptionAttribute)Attribute.GetCustomAttribute(field, typeof(DescriptionAttribute));
            return attribute?.Description ?? code.ToString();
        }

        public static int GetCode(this BizCodeEnum codeEnum) => (int)codeEnum;
     
    }

}
